/*
 * @Author: your name
 * @Date: 2021-12-21 14:05:44
 * @LastEditTime: 2021-12-22 17:37:31
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: /am-server/app/controller/student.js
 */
    const { Controller } = require('egg');
    const Message = require('../utils/Message')
/**
* @Controller student-controller:学生相关接口
*/
class StudentController extends Controller {

  /**
   * @Router get /student/pageQuery
   * @summary 分页查询学生信息
   * @request query string *page
   * @request query string *pageSize
   * @apikey
  */
  async pageQuery () {
    // console.log('====');
    const { ctx, service } = this
    // 接受用户请求 
    // 获取用户参数 ctx.query 
    // 调用service查询
    const studentsVM = await service.student.pageQuery(ctx.query)
    ctx.body = Message.success(studentsVM)
  }
    
  
  /**
   * @Router post /student/saveOrUpdate
   * @summary 保存或修改学生信息
   * @request query number *id
   * @request query string *name
   * @apikey
  */
    async saveOrUpdate () {
        const { ctx, service } = this
    // 接受用户请求 
    // 获取用户参数 ctx.query 
    // 调用service查询
    await service.student.saveOrUpdate(ctx.query)
    ctx.body = Message.success("操作成功")
    }
      
}

module.exports = StudentController;
